<?php
    class Common
    {
        const STATUS_ACTIVED = 1;
        const STATUS_INACTIVED = 0;
        
        public function cut_string($str,$len,$more) {
            if ($str=='' || $str==NULL) return $str;
            if (is_array($str)) return $str;
            $str = trim($str);
            if (strlen($str) <= $len) return $str;
            $str = substr($str,0,$len);
            if ($str != '') {
                if (!substr_count($str," ")) {
                    if ($more) $str .= " ...";
                    return $str;
                }
                while(strlen($str) && ($str[strlen($str)-1] != " ")) $str = substr($str,0,-1);
                $str = substr($str,0,-1);
                if ($more) $str .= " ...";
            }
            return $str;
        }
        
        public function getStatus($status) {
            if($status == '1') {
                $output .= '<img src="'.Yii::app()->request->baseUrl.'/css/backend/images/publish.png">';
            }
            else {
                $output .= '<img src="'.Yii::app()->request->baseUrl.'/css/backend/images/unpublish.png">';
            }
            return $output;
        }
    }
